package com.example.bootdemo.mq.consumer;

import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 消费者，监听消息,消费消息
 * 监听组：监听topic：监听tag（默认监听topic下所有）
 * 监听消费模式：默认负载均衡：CLUSTRRING（每个消息只发给一个消费者）、广播模式：BROADCASTING（发给所有消费者）
 */
@Component
@RocketMQMessageListener(topic = "${rocketmq.producer.topic}", consumerGroup = "${rocketmq.consumer.group}")
public class Consumer0 implements RocketMQListener<String> {


    @Override
    public void onMessage(String s) {
        System.out.println("消费者监听到消息0：>>> :" + s);

//        String s1 = new String(s.getBody());
//        System.out.println("消费者监听到消息内容：>>> :" + s1);
    }
}
